import request from '@/config/axios'

export interface CardkeyProductVO {
  customDenomination: boolean
  id: number
  entityId: string
  productLineId: string
  configurationId: string
  upc: string
  startDate: Date
  endDate: Date
  locale: string
  currencyCode: string
  productDetailData: string
  source: number
  productNo: string
  productName: string
  productDescription: string
  denominationMin: number
  denominationMax: number
  denominationFixed: number
  costPrice: number
  fulfillmentMethod: string
  remark: string
}

// 查询卡密商品列表
export const getCardkeyProductPage = async (params) => {
  return await request.get({url: '/digital/cardkey-product/page', params})
}

// 查询卡密商品详情
export const getCardkeyProduct = async (id: number) => {
  return await request.get({url: '/digital/cardkey-product/get?id=' + id})
}

// 新增卡密商品
export const createCardkeyProduct = async (data: CardkeyProductVO) => {
  return await request.post({url: '/digital/cardkey-product/create', data})
}

// 修改卡密商品
export const updateCardkeyProduct = async (data: CardkeyProductVO) => {
  return await request.put({url: '/digital/cardkey-product/update', data})
}

// 删除卡密商品
export const deleteCardkeyProduct = async (id: number) => {
  return await request.delete({url: '/digital/cardkey-product/delete?id=' + id})
}

// 导出卡密商品 Excel
export const exportCardkeyProductApi = async (params) => {
  return await request.download({url: '/digital/cardkey-product/export-excel', params})
}

// 导入卡密商品 Excel
export const importCardkeyProductApi = async (data) => {
  return await request.post({url: '/digital/cardkey-product/import-excel', data, headersType: 'multipart/form-data'})
}

// 根据卡密编号获取卡密信息
export const getCardkeyByNo = async (params) => {
  return await request.get({url: '/digital/cardkey-product/get-by-no', params})
}

// 预览卡密
export const previewCardkey = async (data) => {
  return await request.post({url: '/digital/cardkey-secret/preview', data})
}

// 获取卡密
export const getByOrderNo = async (params) => {
  return await request.get({url: '/digital/cardkey-secret/get-by-order-no', params})
}


